<template>
    <div>
        <el-form :model="transfer" style="width: 100%;" label-width="80px" ref="menuinfo" >
            <ElFormItem prop="MenuName" label="转移原因">
                <ElInput placeholder="请输入你的转移原因" v-model="transfer.Desc"></ElInput>
            </ElFormItem>
            <ElFormItem label="转交人">
                <el-select v-model="transfer.UnderUserId" placeholder="请选择转交人" style="width: 100%">
                    <el-option
                    v-for="item in UsreList"
                    :key="item.Id"
                    :label="item.UserName"
                    :value="item.Id"
                    />
                </el-select>
            </ElFormItem>
          
            <ElFormItem>
                <ElButton @click.prevent="submit" type="primary" >提交</ElButton>
            </ElFormItem>
        </el-form>
    </div>
</template>

<script setup lang="ts">
import taskTransfer from '@/api/taskTransferapi';
import userapi from '@/api/userapi';
import { ElMessage } from 'element-plus';
import { onMounted, ref } from 'vue';

const props = defineProps({
    Id:Number
})
const UsreList = ref();
const transfer = ref({
    TaskId:props.Id,
    UnderUserId:"",
    Desc:"",
});
const emits = defineEmits(["CloesDialog"])
const getmanger = () => {
    userapi.Getshi().then(res => {
        UsreList.value = res.data;
    }).catch(err => {
        console.log(err)
    })
}
const submit =()=>{
	
    taskTransfer.add(transfer.value).then(res=>{		
        if (res.code > 0) {
            ElMessage.success("成功")
			console.log("B123=",transfer.value)
            emits("CloesDialog","transfer")
        }else{
            ElMessage.error("失败")
        }
    }).catch(err=>{
        console.log(err)
    })
}

onMounted(()=>{
    getmanger()
})
</script>

<style scoped>

</style>